package main

import (
	"fmt"
	"math"
	"time"
)

var chans = make(chan int, 5)

func main() {
	//runtime.GOMAXPROCS(1)
	for i := 1; i < 101; i++ {
		go getSqrt(i)
	}
	for {
	}
}

func getSqrt(n int) {
	//写入 chans，能够写进去就执行后面的代码，不能执行就阻塞
	chans <- n
	ret := math.Sqrt(float64(n))
	fmt.Println(ret)
	time.Sleep(3 * time.Second)
	<-chans
}
